<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="java.util.Collection,java.util.Iterator"%>
<%@page import="com.bbs.util.MysqlDB,com.bbs.bean.Topic,com.bbs.bean.Login"%>
<jsp:useBean id="topicList" scope="application"
	class="com.bbs.util.MysqlDB" />

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>" />
		<title>JSP论坛 -- 首页</title>
		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="keywords" content="论坛,BBS,JSP论坛,软件工程学院,首页" />
		<meta name="description" content="JSP论坛  我们交流的平台" />	
		<meta name="author" content="软件工程学院" />
		<meta name="copyright" content="2010-2012 成都信息工程学院软件工程学院软工104" />
		<meta http-equiv="Page-Enter"
			content="revealTrans(duration=2,transtion=23)" />
		<meta http-equiv="Page-Exit"
			content="revealTrans(duration=2，transtion=23)" />
		<link rel="shortcut icon" href="images/favicon.ico"
			type="image/x-icon" />
		<link rel="stylesheet" type="text/css" href="css/common.css" />
		<script src="js/search.js" type="text/javascript"></script>
	</head>

	<body>
		<div id="main">
			<%@include file="pages/head.jsp"%>			
			<table id="topicList" frame="void">
				<tr bgcolor="#E6E6E6">
					<form method="post" action="search">
						<td align="left">&nbsp;&nbsp;搜索<input type="text" maxlengh="16" name="search" id="search" value="按帖子内容搜索" onchange="check()"><input type="submit" value="搜索" ></td>
					</form>
					
				</tr>
				<tr bgcolor="#E6E6E6">
					<th width="750px" align="left" class="topicTitleList">
						标题
					</th>
					<th width="90px" align="center">
						发帖日期
					</th>
					<th width="30px" align="center">
						点击
					</th>
					<%
						if (userType != 0) {
					%>
					<th width="40px" align="center">
						删除
					</th>
					<th width="100px" align="center">
						审核
					</th>
					<%
						}
					%>
				</tr>
				<%
					Collection dxk = topicList.getTopics();
					Iterator it = dxk.iterator();
					int i = 1;
					String bg;
					while (it.hasNext()) {
						if (i % 2 == 0) {
							bg = "#FFFFFF";
						} else {
							bg = "#d7eafb";
						}
						Topic topic = (Topic) it.next();
						String topicTitle = topic.getTopicTitle();
						String topicContent = topic.getTopicContent();
						int view = topic.getView();
						int locked = topic.getLocked();
						int topicId = topic.getTopicId();
						String topicTime = topic.getTopicTime();
						int replyCount = topic.getReplyCount();
				%>
				<tr bgcolor="<%=bg%>">
					<td align="left" class="topicTitleList">
						<a href="viewContent?topicId=<%=topicId%>"><%=topicTitle%></a>
					</td>
					<td align="center"><%=topicTime%></td>
					<td align="center"><%=view%></td>
					<%
						if (userType != 0) {
					%>
					<td>
						<a href="deleteTopic?topicId=<%=topicId%>">删除</a>
					</td>
					<td>
						<a href="closeTopic?topicId=<%=topicId%>&locked=<%=locked%>">
							<%
								if (locked == 1) {
											out.print("审核不通过");
										} else {
											out.print("审核通过");
										}
							%> </a>
					</td>
					<%
						}
							i++;
					%>
				</tr>
				<%
					}
				%>
			</table>
			<jsp:include page="pages/foot.jsp" />
		</div>
	</body>
</html>